package com.bwie.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bwie.mapper.TbCustCouponMapper;
import com.bwie.pojo.TbCoupon;
import com.bwie.pojo.TbCustCoupon;
import com.bwie.service.TbCouponService;
import com.bwie.mapper.TbCouponMapper;
import com.bwie.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.xml.crypto.Data;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.util.Date;

/**
* @author 28242
* @description 针对表【tb_coupon】的数据库操作Service实现
* @createDate 2025-07-11 19:21:05
*/
@Service
public class TbCouponServiceImpl extends ServiceImpl<TbCouponMapper, TbCoupon>
    implements TbCouponService{


    @Autowired
    TbCustCouponMapper tbCustCouponMapper;

    @Override
    public void SaveCoupon(Integer custId) {

        TbCustCoupon tbCustCoupon = new TbCustCoupon();
        tbCustCoupon.setCouponId(1);
        tbCustCoupon.setCustomerId(custId);
        tbCustCoupon.setCreateTime(new Date());

        Date date = new Date();
        ZonedDateTime zonedDateTime = date.toInstant().atZone(ZoneId.systemDefault());
        ZonedDateTime zonedDateTime1 = zonedDateTime.plusDays(5);
        Date from = Date.from(zonedDateTime1.toInstant());
        tbCustCoupon.setEndTime(from);
        tbCustCouponMapper.insert(tbCustCoupon);

    }
}




